<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\grid\GridView;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '报名管理';
$this->params['breadcrumbs'][] = $this->title;
$isShow = \Yii::$app->session->hasFlash('success') == false ? '0' : '1';

$model_title = isset(\Yii::$app->params['isvote']['status']) ? '0' : '1';
$model_message = isset(\Yii::$app->params['isvote']['message']) ? \Yii::$app->params['isvote']['message'] : '全部填写完后可报名';
?>
<div ng-app="myApp" ng-controller="myCtrl" ng-init="myInit()">
    <div class="panel panel-default" style="margin-top:15px;">
      <div class="panel-heading">报名管理</div>
      <div class="panel-body">
        <div class="signup-form">
            <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data','id' => 'postform']]) ?>

            <?= $form->field($model, 'name')->textInput(['maxlength' => true, 'placeholder' => '姓名', 'ng-model' => 'name', 'ng-disabled' => 'isDisabled']) ?>

            <?= $form->field($model, 'tel')->textInput(['maxlength' => true, 'placeholder' => '例:15088888888', 'ng-model' => 'tel', 'ng-disabled' => 'isDisabled']) ?>

            <div class="form-group">
                <?= Html::Button('{{ subtitle }}', ['class' => 'btn btn-danger btn-sm btn-block', "ng-click"=>"isClick()", "ng-disabled"=>"isDisabled"]) ?>
            </div>

            <?php ActiveForm::end(); ?>

        </div>
      </div>
    </div>
</div>

<!-- Modal -->
<div class="modal fade" id="showModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">提示</h4>
      </div>
      <div class="modal-body text-center">
            报名成功
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>

<!-- Modal -->
<div class="modal fade" id="focusModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">提示</h4>
      </div>
      <div class="modal-body text-center">
        长按图片，识别图中二维码。<br>
        <img src="http://www.lsol.com.cn/ad/lsol_wx.jpg" /><br>
        关注丽水在线微信号，点击底部导航栏“投票评选”。
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.subtitle = "<?= $model_message?>";
    $scope.isFocus = <?= isset(\Yii::$app->params['isfocus']) ? \Yii::$app->params['isfocus'] : '1'?>;
    $scope.isModel = <?= $isShow?>;
    $scope.isVote = <?= isset(\Yii::$app->params['isvote']['status']) ? '0' : '1';?>;

    $scope.myInit = function(){
        if($scope.isModel == '1'){
            $('#showModel').modal('show');
        }

        if($scope.isFocus == '0'){
            $('#focusModel').modal('show');
        }
        
        if($scope.isVote == '0'){
            $scope.isDisabled = true;
            $scope.subtitle = "<?= $model_message?>";
        }
    }


    $scope.isClick = function(){
        //if($("#signup-name").val() == '' && $("#signup-tel").val() == '' && $("#signup-idcard").val() == '' && $("#signup-profession").val() == '' && $("#signup-thumb").val() == ''){
        //    $scope.subtitle = '还有没有填写的';
        //}else{
            console.log('提交...');
          //  $scope.isDisabled = true;
        //    return false;
            $("#postform").submit();
          //  $scope.isDisabled = true;

        //}
    }

});
</script>
